package org.sirmupadbapi.persistencia;

import org.sirmupadbapi.beans.Remolquestraspaso;
import java.sql.Date; 
import org.sirmupadbapi.beans.*;
import org.sirmupadbapi.controller.*;
import java.io.Serializable;
import java.util.List;
import java.util.ArrayList;
import java.util.*;
import java.sql.Connection;
import java.sql.Statement;
import java.sql.ResultSet;
import java.sql.PreparedStatement;
import java.util.Map;
import java.util.Iterator;
import java.util.HashMap;
import java.util.Map;
 import javax.sql.DataSource;
import org.sirmupadbapi.generales.Mensajeria;
import org.sirmupadbapi.generales.DataGManager;


/**
*
* @author
*/

public class RemolquestraspasoPersistencia implements Serializable {
private static final long serialVersionUID = 1L;
public static Exception excepcion;
public static boolean esMensaje = false;
public static Connection con = null;
public static java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("org/sirmupadbapi/properties/mensajes");
static DataGManager dataGManager;
static List<Remolquestraspaso> list;

public RemolquestraspasoPersistencia(){
         esMensaje =false;
}


/**
*
* insert()
*/

public static boolean insert (Remolquestraspaso remolquestraspaso ) {
  excepcion = null;
  try {
      esMensaje =false;
   
   
   

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return false;
  }
      PreparedStatement pinsert = null;
      String sql = "insert into remolquestraspaso(IDNUMERACIONTRASPASO,IDREMOLQUE,PLACA,IDRECIBO,IDOLD,TIPOIDOLD,ID,TIPOID,ACTIVO,IDMUNICIPIO,FECHATRASPASO,FECHA,USERNAME)  values(?,?,?,?,?,?,?,?,?,?,?,?,?)";
      pinsert = con.prepareStatement(sql);
              pinsert.setInt(1,remolquestraspaso.getIDNUMERACIONTRASPASO());
        pinsert.setLong(2,remolquestraspaso.getIDREMOLQUE());
        pinsert.setString(3,remolquestraspaso.getPLACA());
        pinsert.setInt(4,remolquestraspaso.getIDRECIBO());
        pinsert.setString(5,remolquestraspaso.getIDOLD());
        pinsert.setString(6,remolquestraspaso.getTIPOIDOLD());
        pinsert.setString(7,remolquestraspaso.getID());
        pinsert.setString(8,remolquestraspaso.getTIPOID());
        pinsert.setString(9,remolquestraspaso.getACTIVO());
        pinsert.setString(10,remolquestraspaso.getIDMUNICIPIO());
        pinsert.setDate(11,remolquestraspaso.getFECHATRASPASO());
        pinsert.setDate(12,remolquestraspaso.getFECHA());
        pinsert.setString(13,remolquestraspaso.getUSERNAME());
      int filas= pinsert.executeUpdate();
      pinsert.close();
      return true;
   } catch (Exception e) {
      excepcion = e;
   } finally {
  }
  return false;
 }


/**
*
* update()
*/

public static boolean update(Remolquestraspaso remolquestraspaso ) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return false;
  }
      PreparedStatement pupdate = null;
      String sql = "update remolquestraspaso set  IDNUMERACIONTRASPASO=?, IDREMOLQUE=?, PLACA=?, IDRECIBO=?, IDOLD=?, TIPOIDOLD=?, ID=?, TIPOID=?, ACTIVO=?, IDMUNICIPIO=?, FECHATRASPASO=?, FECHA=?, USERNAME=?  where  IDNUMERACIONTRASPASO ='"+remolquestraspaso.getIDNUMERACIONTRASPASO()+"' and  IDMUNICIPIO ='"+remolquestraspaso.getIDMUNICIPIO()+"'  ";
      pupdate= con.prepareStatement(sql);
      pupdate.setInt(1,remolquestraspaso.getIDNUMERACIONTRASPASO());
pupdate.setLong(2,remolquestraspaso.getIDREMOLQUE());
pupdate.setString(3,remolquestraspaso.getPLACA());
pupdate.setInt(4,remolquestraspaso.getIDRECIBO());
pupdate.setString(5,remolquestraspaso.getIDOLD());
pupdate.setString(6,remolquestraspaso.getTIPOIDOLD());
pupdate.setString(7,remolquestraspaso.getID());
pupdate.setString(8,remolquestraspaso.getTIPOID());
pupdate.setString(9,remolquestraspaso.getACTIVO());
pupdate.setString(10,remolquestraspaso.getIDMUNICIPIO());
pupdate.setDate(11,remolquestraspaso.getFECHATRASPASO());
pupdate.setDate(12,remolquestraspaso.getFECHA());
pupdate.setString(13,remolquestraspaso.getUSERNAME());
      int filas= pupdate.executeUpdate();
      pupdate.close();
      if (filas <= 0){
          excepcion=new Exception(bundle.getString("msg.noupdate"));
          esMensaje =true;
          return false;
      }
      return true;
   } catch (Exception e) {
      excepcion = e;
   } finally {
  }
  return false;
}


/**
*
* update()
*/

public static boolean update(String sqlupdate ) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return false;
  }
      PreparedStatement pupdate = null;
      String sql = "update  remolquestraspaso set " + sqlupdate +"";
      pupdate= con.prepareStatement(sql);
      int filas= pupdate.executeUpdate();
      pupdate.close();
      if (filas <= 0){
          excepcion=new Exception(bundle.getString("msg.noupdate"));
          esMensaje =true;
          return false;
      }
      return true;
   } catch (Exception e) {
      excepcion = e;
   } finally {
  }
  return false;
}


/**
*
* updatePrimaryKey()
*/

public static boolean updatePrimaryKey(Remolquestraspaso remolquestraspaso_old , Remolquestraspaso remolquestraspaso) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return false;
  }
      PreparedStatement pupdate = null;
      String sql = "update remolquestraspaso set  IDNUMERACIONTRASPASO=? ,  IDMUNICIPIO=?  where  IDNUMERACIONTRASPASO ='"+remolquestraspaso_old.getIDNUMERACIONTRASPASO()+"' and  IDMUNICIPIO ='"+remolquestraspaso_old.getIDMUNICIPIO()+"'  ";
      pupdate= con.prepareStatement(sql);
      pupdate.setInt(1,remolquestraspaso.getIDNUMERACIONTRASPASO());pupdate.setString(10,remolquestraspaso.getIDMUNICIPIO());
      int filas= pupdate.executeUpdate();
      pupdate.close();
      if (filas <= 0){
          excepcion=new Exception(bundle.getString("msg.noupdate"));
          esMensaje =true;
          return false;
      }
      return true;
   } catch (Exception e) {
      excepcion = e;
   } finally {
  }
  return false;
}


/**
*
* delete()
*/

public static boolean delete(Remolquestraspaso remolquestraspaso ) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return false;
  }
      PreparedStatement pdelete = null;
      String sql = "delete from remolquestraspaso  where  IDNUMERACIONTRASPASO = ? and  IDMUNICIPIO = ?  ";
      pdelete= con.prepareStatement(sql);
      pdelete.setInt(1,remolquestraspaso.getIDNUMERACIONTRASPASO());
pdelete.setString(10,remolquestraspaso.getIDMUNICIPIO());
      int filas= pdelete.executeUpdate();
      pdelete.close();
      if (filas <= 0){
          excepcion=new Exception(bundle.getString("msg.nodelete"));
          esMensaje =true;
          return false;
      }
      return true;
   } catch (Exception e) {
      excepcion = e;
   } finally {
  }
  return false;
}


/**
*
* delete()
*/

public static boolean delete(String sqldelete ) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return false;
  }
      PreparedStatement pdelete = null;
      String sql = "delete from remolquestraspaso where " + sqldelete +"";
      pdelete= con.prepareStatement(sql);
      int filas= pdelete.executeUpdate();
      pdelete.close();
      if (filas <= 0){
          excepcion=new Exception(bundle.getString("msg.nodelete"));
          esMensaje =true;
          return false;
      }
      return true;
   } catch (Exception e) {
      excepcion = e;
   } finally {
  }
  return false;
}


/**
*
* deleteAll()
*/

public static boolean deleteAll() {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return false;
  }
      PreparedStatement pdelete = null;
      String sql = "delete from remolquestraspaso  ";
      pdelete= con.prepareStatement(sql);
      int filas= pdelete.executeUpdate();
      pdelete.close();
      if (filas <= 0){
          excepcion=new Exception(bundle.getString("msg.nodeleteall"));
          esMensaje =true;
          return false;
      }
      return true;
   } catch (Exception e) {
      excepcion = e;
   } finally {
  }
  return false;
}


/**
*
* exists()
*/



public static boolean exists(Remolquestraspaso remolquestraspaso) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return false;
  }
      String sql = "select * from remolquestraspaso where IDNUMERACIONTRASPASO='"+remolquestraspaso.getIDNUMERACIONTRASPASO()+"' and IDMUNICIPIO='"+remolquestraspaso.getIDMUNICIPIO()+"'";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "remolquestraspaso" +" " + bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return false;
   }
    rs.close();
    psquery.close();
 return true;
} catch (Exception ex) {
      excepcion = ex;
}
  return false;
}


/**
*
* findByPrimaryKey()
*/



public static Remolquestraspaso findByPrimaryKey(Remolquestraspaso remolquestraspaso) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return null;
  }
      String sql = "select * from remolquestraspaso where IDNUMERACIONTRASPASO='"+remolquestraspaso.getIDNUMERACIONTRASPASO()+"' and IDMUNICIPIO='"+remolquestraspaso.getIDMUNICIPIO()+"'";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "remolquestraspaso" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return null;
   }
   rs.beforeFirst();
   while (rs.next()) {
   
            
            
            remolquestraspaso.setIDNUMERACIONTRASPASO(rs.getInt("IDNUMERACIONTRASPASO"));
remolquestraspaso.setIDREMOLQUE(rs.getLong("IDREMOLQUE"));
remolquestraspaso.setPLACA(rs.getString("PLACA"));
remolquestraspaso.setIDRECIBO(rs.getInt("IDRECIBO"));
remolquestraspaso.setIDOLD(rs.getString("IDOLD"));
remolquestraspaso.setTIPOIDOLD(rs.getString("TIPOIDOLD"));
remolquestraspaso.setID(rs.getString("ID"));
remolquestraspaso.setTIPOID(rs.getString("TIPOID"));
remolquestraspaso.setACTIVO(rs.getString("ACTIVO"));
remolquestraspaso.setIDMUNICIPIO(rs.getString("IDMUNICIPIO"));
remolquestraspaso.setFECHATRASPASO(rs.getDate("FECHATRASPASO"));
remolquestraspaso.setFECHA(rs.getDate("FECHA"));
remolquestraspaso.setUSERNAME(rs.getString("USERNAME"));
    }
    rs.close();
    psquery.close();
 return remolquestraspaso;
} catch (Exception ex) {
      excepcion = ex;
}
  return null;
}


/**
*
* findByIDNUMERACIONTRASPASO()
*/

public static List<Remolquestraspaso> findByIDNUMERACIONTRASPASO(Remolquestraspaso remolquestraspaso,boolean withRelation) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return null;
  }
       list = new ArrayList<Remolquestraspaso>();
      String sql = "select * from remolquestraspaso where IDNUMERACIONTRASPASO='"+remolquestraspaso.getIDNUMERACIONTRASPASO()+"'";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "remolquestraspaso" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return null;
   }
   rs.beforeFirst();
   while (rs.next()) {
   
        Remolquestraspaso remolquestraspaso2 = new Remolquestraspaso(
         rs.getInt("IDNUMERACIONTRASPASO"),rs.getLong("IDREMOLQUE"),rs.getString("PLACA"),rs.getInt("IDRECIBO"),rs.getString("IDOLD"),rs.getString("TIPOIDOLD"),rs.getString("ID"),rs.getString("TIPOID"),rs.getString("ACTIVO"),rs.getString("IDMUNICIPIO"),rs.getDate("FECHATRASPASO"),rs.getDate("FECHA"),rs.getString("USERNAME"));
            
            
       list.add(remolquestraspaso2);
    }
    rs.close();
    psquery.close();
    return list;
} catch (Exception ex) {
      excepcion = ex;
}
  return null;
}


/**
*
* findByIDREMOLQUE()
*/

public static List<Remolquestraspaso> findByIDREMOLQUE(Remolquestraspaso remolquestraspaso,boolean withRelation) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return null;
  }
       list = new ArrayList<Remolquestraspaso>();
      String sql = "select * from remolquestraspaso where IDREMOLQUE='"+remolquestraspaso.getIDREMOLQUE()+"'";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "remolquestraspaso" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return null;
   }
   rs.beforeFirst();
   while (rs.next()) {
   
        Remolquestraspaso remolquestraspaso2 = new Remolquestraspaso(
         rs.getInt("IDNUMERACIONTRASPASO"),rs.getLong("IDREMOLQUE"),rs.getString("PLACA"),rs.getInt("IDRECIBO"),rs.getString("IDOLD"),rs.getString("TIPOIDOLD"),rs.getString("ID"),rs.getString("TIPOID"),rs.getString("ACTIVO"),rs.getString("IDMUNICIPIO"),rs.getDate("FECHATRASPASO"),rs.getDate("FECHA"),rs.getString("USERNAME"));
            
            
       list.add(remolquestraspaso2);
    }
    rs.close();
    psquery.close();
    return list;
} catch (Exception ex) {
      excepcion = ex;
}
  return null;
}


/**
*
* findByPLACA()
*/

public static List<Remolquestraspaso> findByPLACA(Remolquestraspaso remolquestraspaso,boolean withRelation) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return null;
  }
       list = new ArrayList<Remolquestraspaso>();
      String sql = "select * from remolquestraspaso where PLACA='"+remolquestraspaso.getPLACA()+"'";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "remolquestraspaso" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return null;
   }
   rs.beforeFirst();
   while (rs.next()) {
   
        Remolquestraspaso remolquestraspaso2 = new Remolquestraspaso(
         rs.getInt("IDNUMERACIONTRASPASO"),rs.getLong("IDREMOLQUE"),rs.getString("PLACA"),rs.getInt("IDRECIBO"),rs.getString("IDOLD"),rs.getString("TIPOIDOLD"),rs.getString("ID"),rs.getString("TIPOID"),rs.getString("ACTIVO"),rs.getString("IDMUNICIPIO"),rs.getDate("FECHATRASPASO"),rs.getDate("FECHA"),rs.getString("USERNAME"));
            
            
       list.add(remolquestraspaso2);
    }
    rs.close();
    psquery.close();
    return list;
} catch (Exception ex) {
      excepcion = ex;
}
  return null;
}


/**
*
* findByIDRECIBO()
*/

public static List<Remolquestraspaso> findByIDRECIBO(Remolquestraspaso remolquestraspaso,boolean withRelation) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return null;
  }
       list = new ArrayList<Remolquestraspaso>();
      String sql = "select * from remolquestraspaso where IDRECIBO='"+remolquestraspaso.getIDRECIBO()+"'";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "remolquestraspaso" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return null;
   }
   rs.beforeFirst();
   while (rs.next()) {
   
        Remolquestraspaso remolquestraspaso2 = new Remolquestraspaso(
         rs.getInt("IDNUMERACIONTRASPASO"),rs.getLong("IDREMOLQUE"),rs.getString("PLACA"),rs.getInt("IDRECIBO"),rs.getString("IDOLD"),rs.getString("TIPOIDOLD"),rs.getString("ID"),rs.getString("TIPOID"),rs.getString("ACTIVO"),rs.getString("IDMUNICIPIO"),rs.getDate("FECHATRASPASO"),rs.getDate("FECHA"),rs.getString("USERNAME"));
            
            
       list.add(remolquestraspaso2);
    }
    rs.close();
    psquery.close();
    return list;
} catch (Exception ex) {
      excepcion = ex;
}
  return null;
}


/**
*
* findByIDOLD()
*/

public static List<Remolquestraspaso> findByIDOLD(Remolquestraspaso remolquestraspaso,boolean withRelation) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return null;
  }
       list = new ArrayList<Remolquestraspaso>();
      String sql = "select * from remolquestraspaso where IDOLD='"+remolquestraspaso.getIDOLD()+"'";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "remolquestraspaso" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return null;
   }
   rs.beforeFirst();
   while (rs.next()) {
   
        Remolquestraspaso remolquestraspaso2 = new Remolquestraspaso(
         rs.getInt("IDNUMERACIONTRASPASO"),rs.getLong("IDREMOLQUE"),rs.getString("PLACA"),rs.getInt("IDRECIBO"),rs.getString("IDOLD"),rs.getString("TIPOIDOLD"),rs.getString("ID"),rs.getString("TIPOID"),rs.getString("ACTIVO"),rs.getString("IDMUNICIPIO"),rs.getDate("FECHATRASPASO"),rs.getDate("FECHA"),rs.getString("USERNAME"));
            
            
       list.add(remolquestraspaso2);
    }
    rs.close();
    psquery.close();
    return list;
} catch (Exception ex) {
      excepcion = ex;
}
  return null;
}


/**
*
* findByTIPOIDOLD()
*/

public static List<Remolquestraspaso> findByTIPOIDOLD(Remolquestraspaso remolquestraspaso,boolean withRelation) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return null;
  }
       list = new ArrayList<Remolquestraspaso>();
      String sql = "select * from remolquestraspaso where TIPOIDOLD='"+remolquestraspaso.getTIPOIDOLD()+"'";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "remolquestraspaso" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return null;
   }
   rs.beforeFirst();
   while (rs.next()) {
   
        Remolquestraspaso remolquestraspaso2 = new Remolquestraspaso(
         rs.getInt("IDNUMERACIONTRASPASO"),rs.getLong("IDREMOLQUE"),rs.getString("PLACA"),rs.getInt("IDRECIBO"),rs.getString("IDOLD"),rs.getString("TIPOIDOLD"),rs.getString("ID"),rs.getString("TIPOID"),rs.getString("ACTIVO"),rs.getString("IDMUNICIPIO"),rs.getDate("FECHATRASPASO"),rs.getDate("FECHA"),rs.getString("USERNAME"));
            
            
       list.add(remolquestraspaso2);
    }
    rs.close();
    psquery.close();
    return list;
} catch (Exception ex) {
      excepcion = ex;
}
  return null;
}


/**
*
* findByID()
*/

public static List<Remolquestraspaso> findByID(Remolquestraspaso remolquestraspaso,boolean withRelation) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return null;
  }
       list = new ArrayList<Remolquestraspaso>();
      String sql = "select * from remolquestraspaso where ID='"+remolquestraspaso.getID()+"'";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "remolquestraspaso" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return null;
   }
   rs.beforeFirst();
   while (rs.next()) {
   
        Remolquestraspaso remolquestraspaso2 = new Remolquestraspaso(
         rs.getInt("IDNUMERACIONTRASPASO"),rs.getLong("IDREMOLQUE"),rs.getString("PLACA"),rs.getInt("IDRECIBO"),rs.getString("IDOLD"),rs.getString("TIPOIDOLD"),rs.getString("ID"),rs.getString("TIPOID"),rs.getString("ACTIVO"),rs.getString("IDMUNICIPIO"),rs.getDate("FECHATRASPASO"),rs.getDate("FECHA"),rs.getString("USERNAME"));
            
            
       list.add(remolquestraspaso2);
    }
    rs.close();
    psquery.close();
    return list;
} catch (Exception ex) {
      excepcion = ex;
}
  return null;
}


/**
*
* findByTIPOID()
*/

public static List<Remolquestraspaso> findByTIPOID(Remolquestraspaso remolquestraspaso,boolean withRelation) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return null;
  }
       list = new ArrayList<Remolquestraspaso>();
      String sql = "select * from remolquestraspaso where TIPOID='"+remolquestraspaso.getTIPOID()+"'";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "remolquestraspaso" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return null;
   }
   rs.beforeFirst();
   while (rs.next()) {
   
        Remolquestraspaso remolquestraspaso2 = new Remolquestraspaso(
         rs.getInt("IDNUMERACIONTRASPASO"),rs.getLong("IDREMOLQUE"),rs.getString("PLACA"),rs.getInt("IDRECIBO"),rs.getString("IDOLD"),rs.getString("TIPOIDOLD"),rs.getString("ID"),rs.getString("TIPOID"),rs.getString("ACTIVO"),rs.getString("IDMUNICIPIO"),rs.getDate("FECHATRASPASO"),rs.getDate("FECHA"),rs.getString("USERNAME"));
            
            
       list.add(remolquestraspaso2);
    }
    rs.close();
    psquery.close();
    return list;
} catch (Exception ex) {
      excepcion = ex;
}
  return null;
}


/**
*
* findByACTIVO()
*/

public static List<Remolquestraspaso> findByACTIVO(Remolquestraspaso remolquestraspaso,boolean withRelation) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return null;
  }
       list = new ArrayList<Remolquestraspaso>();
      String sql = "select * from remolquestraspaso where ACTIVO='"+remolquestraspaso.getACTIVO()+"'";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "remolquestraspaso" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return null;
   }
   rs.beforeFirst();
   while (rs.next()) {
   
        Remolquestraspaso remolquestraspaso2 = new Remolquestraspaso(
         rs.getInt("IDNUMERACIONTRASPASO"),rs.getLong("IDREMOLQUE"),rs.getString("PLACA"),rs.getInt("IDRECIBO"),rs.getString("IDOLD"),rs.getString("TIPOIDOLD"),rs.getString("ID"),rs.getString("TIPOID"),rs.getString("ACTIVO"),rs.getString("IDMUNICIPIO"),rs.getDate("FECHATRASPASO"),rs.getDate("FECHA"),rs.getString("USERNAME"));
            
            
       list.add(remolquestraspaso2);
    }
    rs.close();
    psquery.close();
    return list;
} catch (Exception ex) {
      excepcion = ex;
}
  return null;
}


/**
*
* findByIDMUNICIPIO()
*/

public static List<Remolquestraspaso> findByIDMUNICIPIO(Remolquestraspaso remolquestraspaso,boolean withRelation) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return null;
  }
       list = new ArrayList<Remolquestraspaso>();
      String sql = "select * from remolquestraspaso where IDMUNICIPIO='"+remolquestraspaso.getIDMUNICIPIO()+"'";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "remolquestraspaso" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return null;
   }
   rs.beforeFirst();
   while (rs.next()) {
   
        Remolquestraspaso remolquestraspaso2 = new Remolquestraspaso(
         rs.getInt("IDNUMERACIONTRASPASO"),rs.getLong("IDREMOLQUE"),rs.getString("PLACA"),rs.getInt("IDRECIBO"),rs.getString("IDOLD"),rs.getString("TIPOIDOLD"),rs.getString("ID"),rs.getString("TIPOID"),rs.getString("ACTIVO"),rs.getString("IDMUNICIPIO"),rs.getDate("FECHATRASPASO"),rs.getDate("FECHA"),rs.getString("USERNAME"));
            
            
       list.add(remolquestraspaso2);
    }
    rs.close();
    psquery.close();
    return list;
} catch (Exception ex) {
      excepcion = ex;
}
  return null;
}


/**
*
* findByFECHATRASPASO()
*/

public static List<Remolquestraspaso> findByFECHATRASPASO(Remolquestraspaso remolquestraspaso,boolean withRelation) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return null;
  }
       list = new ArrayList<Remolquestraspaso>();
      String sql = "select * from remolquestraspaso where FECHATRASPASO='"+remolquestraspaso.getFECHATRASPASO()+"'";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "remolquestraspaso" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return null;
   }
   rs.beforeFirst();
   while (rs.next()) {
   
        Remolquestraspaso remolquestraspaso2 = new Remolquestraspaso(
         rs.getInt("IDNUMERACIONTRASPASO"),rs.getLong("IDREMOLQUE"),rs.getString("PLACA"),rs.getInt("IDRECIBO"),rs.getString("IDOLD"),rs.getString("TIPOIDOLD"),rs.getString("ID"),rs.getString("TIPOID"),rs.getString("ACTIVO"),rs.getString("IDMUNICIPIO"),rs.getDate("FECHATRASPASO"),rs.getDate("FECHA"),rs.getString("USERNAME"));
            
            
       list.add(remolquestraspaso2);
    }
    rs.close();
    psquery.close();
    return list;
} catch (Exception ex) {
      excepcion = ex;
}
  return null;
}


/**
*
* findByFECHA()
*/

public static List<Remolquestraspaso> findByFECHA(Remolquestraspaso remolquestraspaso,boolean withRelation) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return null;
  }
       list = new ArrayList<Remolquestraspaso>();
      String sql = "select * from remolquestraspaso where FECHA='"+remolquestraspaso.getFECHA()+"'";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "remolquestraspaso" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return null;
   }
   rs.beforeFirst();
   while (rs.next()) {
   
        Remolquestraspaso remolquestraspaso2 = new Remolquestraspaso(
         rs.getInt("IDNUMERACIONTRASPASO"),rs.getLong("IDREMOLQUE"),rs.getString("PLACA"),rs.getInt("IDRECIBO"),rs.getString("IDOLD"),rs.getString("TIPOIDOLD"),rs.getString("ID"),rs.getString("TIPOID"),rs.getString("ACTIVO"),rs.getString("IDMUNICIPIO"),rs.getDate("FECHATRASPASO"),rs.getDate("FECHA"),rs.getString("USERNAME"));
            
            
       list.add(remolquestraspaso2);
    }
    rs.close();
    psquery.close();
    return list;
} catch (Exception ex) {
      excepcion = ex;
}
  return null;
}


/**
*
* findByUSERNAME()
*/

public static List<Remolquestraspaso> findByUSERNAME(Remolquestraspaso remolquestraspaso,boolean withRelation) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return null;
  }
       list = new ArrayList<Remolquestraspaso>();
      String sql = "select * from remolquestraspaso where USERNAME='"+remolquestraspaso.getUSERNAME()+"'";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "remolquestraspaso" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return null;
   }
   rs.beforeFirst();
   while (rs.next()) {
   
        Remolquestraspaso remolquestraspaso2 = new Remolquestraspaso(
         rs.getInt("IDNUMERACIONTRASPASO"),rs.getLong("IDREMOLQUE"),rs.getString("PLACA"),rs.getInt("IDRECIBO"),rs.getString("IDOLD"),rs.getString("TIPOIDOLD"),rs.getString("ID"),rs.getString("TIPOID"),rs.getString("ACTIVO"),rs.getString("IDMUNICIPIO"),rs.getDate("FECHATRASPASO"),rs.getDate("FECHA"),rs.getString("USERNAME"));
            
            
       list.add(remolquestraspaso2);
    }
    rs.close();
    psquery.close();
    return list;
} catch (Exception ex) {
      excepcion = ex;
}
  return null;
}


/**
*
* locateByParameters()
*/

public static List<Remolquestraspaso> locateByParameters(Map parametros,boolean withRelation) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return null;
  }
       list = new ArrayList<Remolquestraspaso>();
  String sql = "select * from remolquestraspaso";
  if (parametros != null) {
      Iterator it = parametros.entrySet().iterator();
      StringBuilder sb = new StringBuilder("");
      int i = 0;
      while (it.hasNext()) {
          if (i != 0){
            sb.append(" and ");
         }
         i++;
        Map.Entry e = (Map.Entry) it.next();
        sb.append(e.getKey() +"= '"+  e.getValue()+"'");
      }
      if (!sb.toString().equals("")){
         sql = sql + " where " + sb.toString();
      }
   }
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "remolquestraspaso" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return null;
   }
   rs.beforeFirst();
   while (rs.next()) {
   
        Remolquestraspaso remolquestraspaso2 = new Remolquestraspaso(
         rs.getInt("IDNUMERACIONTRASPASO"),rs.getLong("IDREMOLQUE"),rs.getString("PLACA"),rs.getInt("IDRECIBO"),rs.getString("IDOLD"),rs.getString("TIPOIDOLD"),rs.getString("ID"),rs.getString("TIPOID"),rs.getString("ACTIVO"),rs.getString("IDMUNICIPIO"),rs.getDate("FECHATRASPASO"),rs.getDate("FECHA"),rs.getString("USERNAME"));
            
            
       list.add(remolquestraspaso2);
    }
    rs.close();
    psquery.close();
    return list;
} catch (Exception ex) {
      excepcion = ex;
}
  return null;
}


/**
*
* Double fFunc(String funcion, String campo)
*/



public static Double func(String funcion, String campo) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return 0.0;
  }
      String sql = "select "+funcion+"("+campo+") as contador from remolquestraspaso";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "remolquestraspaso" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return 0.0;
   }
    Double tmp =0.0;
   rs.beforeFirst();
   while (rs.next()) {
    tmp =  rs.getDouble("contador");
    }
    rs.close();
    psquery.close();
 return tmp;
} catch (Exception ex) {
      excepcion = ex;
}
  return 0.0;
}


/**
*
* Double func(String funcion, String campo,String where)
*/



public static Double func(String funcion, String campo, String where) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return 0.0;
  }
      String sql = "select "+funcion+"("+campo+") as contador from remolquestraspaso where "+where +" ";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "remolquestraspaso" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return 0.0;
   }
    Double tmp =0.0;
   rs.beforeFirst();
   while (rs.next()) {
    tmp =  rs.getDouble("contador");
    }
    rs.close();
    psquery.close();
 return tmp;
} catch (Exception ex) {
      excepcion = ex;
}
  return 0.0;
}


/**
*
* count()
*/



public static Integer count() {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return 0;
  }
      String sql = "select count(*) as contador from remolquestraspaso";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "remolquestraspaso" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return 0;
   }
   rs.beforeFirst();
   while (rs.next()) {
    x =  rs.getInt("contador");
    }
    rs.close();
    psquery.close();
 return x;
} catch (Exception ex) {
      excepcion = ex;
}
  return 0;
}


/**
*
* count(String sqlquery)
*/



public static Integer count(String sqlquery) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return 0;
  }
      String sql = "select count(*) as contador from remolquestraspaso where  " + sqlquery +"";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "remolquestraspaso" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return 0;
   }
   rs.beforeFirst();
   while (rs.next()) {
    x =  rs.getInt("contador");
    }
    rs.close();
    psquery.close();
 return x;
} catch (Exception ex) {
      excepcion = ex;
}
  return 0;
}


/**
*
* query()
*/

public static List<Remolquestraspaso> query(String query,boolean withRelation) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return null;
  }
        list = new ArrayList<Remolquestraspaso>();
  String sql = "select * from remolquestraspaso where " + query +"";
  if (query == null || query.equals("")) {
  return null;
   }
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "remolquestraspaso" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return null;
   }
   rs.beforeFirst();
   while (rs.next()) {
   
        Remolquestraspaso remolquestraspaso2 = new Remolquestraspaso(
         rs.getInt("IDNUMERACIONTRASPASO"),rs.getLong("IDREMOLQUE"),rs.getString("PLACA"),rs.getInt("IDRECIBO"),rs.getString("IDOLD"),rs.getString("TIPOIDOLD"),rs.getString("ID"),rs.getString("TIPOID"),rs.getString("ACTIVO"),rs.getString("IDMUNICIPIO"),rs.getDate("FECHATRASPASO"),rs.getDate("FECHA"),rs.getString("USERNAME"));
            
            
       list.add(remolquestraspaso2);
    }
    rs.close();
    psquery.close();
    return list;
} catch (Exception ex) {
      excepcion = ex;
}
  return null;
}


/**
*
* getListRecords()
*/

public static List<Remolquestraspaso> getListRecords(Map parametros,boolean withRelation) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return null;
  }
      list = new ArrayList<Remolquestraspaso>();
  String sql = "select * from remolquestraspaso";
  if (parametros != null) {
      Iterator it = parametros.entrySet().iterator();
      StringBuilder sb = new StringBuilder("");
      while (it.hasNext()) {
        Map.Entry e = (Map.Entry) it.next();
        sb.append(e.getKey() +"="+  e.getValue());
      }
      if (!sb.toString().equals("")){
         sql = sql + " where " + sb.toString();
      }
   }
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "remolquestraspaso" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return null;
   }
   rs.beforeFirst();
   while (rs.next()) {
       
        Remolquestraspaso remolquestraspaso2 = new Remolquestraspaso(
         rs.getInt("IDNUMERACIONTRASPASO"),rs.getLong("IDREMOLQUE"),rs.getString("PLACA"),rs.getInt("IDRECIBO"),rs.getString("IDOLD"),rs.getString("TIPOIDOLD"),rs.getString("ID"),rs.getString("TIPOID"),rs.getString("ACTIVO"),rs.getString("IDMUNICIPIO"),rs.getDate("FECHATRASPASO"),rs.getDate("FECHA"),rs.getString("USERNAME"));
            
            
       list.add(remolquestraspaso2);
    }
    rs.close();
    psquery.close();
    return list;
} catch (Exception ex) {
      excepcion = ex;
}
  return null;
 }


}
